from fastapi import Request, Response
from fastapi.routing import APIRoute
from afast_core.core_libs.classy_apirouter.group_router import RestInjectForAPIRouter, RestInjectForDocRouter
from infirmary_admin_src.infirmary_common.infirmary_controller import IBaseController
from afast_core.core_libs.classy_apirouter import IHookGroupBaseController
from afast_core.core_libs.classy_apirouter import get, post
from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.system.role.controllers.add import SystemRoleAddController

from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.system.role.controllers.delete import \
    SystemRoleDeleteController
from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.system.role.controllers.employee_batchAddRoleEmployee import \
    SystemBatchAddRoleEmployeeController
from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.system.role.controllers.employee_batch_removeEmployee import \
    SystemEmployeeBatchRemoveEmployeeController
from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.system.role.controllers.employee_queryEmployee import \
    SystemRoleEmployeeQueryEmployeeController
from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.system.role.controllers.employee_removeEmployee import \
    SystemEmployeeRemoveEmployeeController
from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.system.role.controllers.getAllEmployeeByRoleId import \
    SystemGetAllEmployeeByRoleIdController
from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.system.role.controllers.getRoleDataScopeList_byid import \
    SystemGetRoleDataScopeListByidController

from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.system.role.controllers.getRoleSelectedMenu_byid import \
    SystemGetRoleSelectedMenuByidController
from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.system.role.controllers.list_all import \
    SystemRoleAllController
from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.system.role.controllers.menu_updateRoleMenu import \
    SystemMenuUpdateRoleMenuController
from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.system.role.controllers.update import \
    SystemRoleUpdateController


#  tags=['测试类装饰器依赖项']

@RestInjectForAPIRouter(prefix='/role')
@RestInjectForDocRouter(tags=['后台系统-人员管理模块'])
class AGroupAPIRouterBuilder(IHookGroupBaseController):
    # 定义公共全局的可用的服务，通过request对象进行透传当前的self

    async def before_request(self, curr_apiroute: APIRoute, request: Request) -> None:
        """如果需要修改请求信息，可直接重写此方法"""
        pass
        request.state.api_router_builder = self
        # 如果存在body对象的，在这里读取一下，以备后续的使用
        request.state.schema_param_body = await request.body()
        print("request.state.schema_param_body ", request.state.schema_param_body)

    async def after_request(self, request: Request, response: Response) -> None:
        """请求后的处理"""
        pass

    @get("/getAll", summary='菜单模块-菜单列表信息获取')
    def admin_role_getAll(self, controller: IBaseController = SystemRoleAllController):
        return controller.sync_response()

    @post("/update", summary='菜单模块-菜单列表信息获取')
    def admin_role_update(self, controller: IBaseController = SystemRoleUpdateController):
        return controller.sync_response()

    @post("/add", summary='菜单模块-菜单列表信息获取')
    def admin_role_add(self, controller: IBaseController = SystemRoleAddController):
        return controller.sync_response()

    @get("/delete/{id}", summary='菜单模块-菜单列表信息获取')
    def admin_role_delete(self, controller: IBaseController = SystemRoleDeleteController):
        return controller.sync_response()

    @get("/menu/getRoleSelectedMenu/{id}", summary='菜单模块-获取角色菜单信息')
    def admin_role_getRoleSelectedMenu_byid(self,
                                            controller: IBaseController = SystemGetRoleSelectedMenuByidController):
        return controller.sync_response()

    @get("/dataScope/getRoleDataScopeList/{id}", summary='菜单模块-获取角色菜单信息')
    def admin_role_getRoleDataScopeList_byid(self,
                                             controller: IBaseController = SystemGetRoleDataScopeListByidController):
        return controller.sync_response()

    @post("/employee/queryEmployee", summary='菜单模块-菜单列表信息获取')
    def admin_role_employee_queryEmployee(self,
                                          controller: IBaseController = SystemRoleEmployeeQueryEmployeeController):
        return controller.sync_response()

    @get("/employee/removeEmployee", summary='菜单模块-获取角色菜单信息')
    def admin_role_employee_removeEmployee(self,
                                           controller: IBaseController = SystemEmployeeRemoveEmployeeController):
        return controller.sync_response()

    @post("/employee/batchRemoveRoleEmployee", summary='菜单模块-获取角色菜单信息')
    def admin_role_employee_batchRemoveRoleEmployee(self,
                                                    controller: IBaseController = SystemEmployeeBatchRemoveEmployeeController):
        return controller.sync_response()

    @get("/employee/getAllEmployeeByRoleId/{id}", summary='菜单模块-获取角色菜单信息')
    def admin_role_employee_getAllEmployeeByRoleId(self,
                                                   controller: IBaseController = SystemGetAllEmployeeByRoleIdController):
        return controller.sync_response()

    @post("/employee/batchAddRoleEmployee", summary='菜单模块-获取角色菜单信息')
    def admin_role_employee_batchAddRoleEmployee(self,
                                                 controller: IBaseController = SystemBatchAddRoleEmployeeController):
        return controller.sync_response()

    @post("/menu/updateRoleMenu", summary='菜单模块-获取角色菜单信息')
    def admin_role_menu_updateRoleMenu(self,
                                       controller: IBaseController = SystemMenuUpdateRoleMenuController):
        return controller.sync_response()
